package RadianceM.DistributionSystem.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenApiConfig {

	/*
	* springDoc文档配置
	*
	* */
	@Bean
	public OpenAPI createOpenAPI() {
		return new OpenAPI()
				.info(getInfo())
				.externalDocs(getExternalDocumentation())
				.components(new Components().addSecuritySchemes("bearer-key",
						new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer")));
	}


	private License getLicense() {
		return new License()
				.name("MIT")
				.url("https://opensource.org/licenses/MIT");
	}

	private Info getInfo() {
		return new Info()
				.title("RadianceM 数字化公寓选调系统 API接口文档")
				.contact(
						new Contact()
								.name("RadianceM")
								.email("2127969635@qq.com")
								.url("https://gitee.com/xiaoting1111111")
				)
				.termsOfService("http://localhost:8081/DS/")
				.description("A project for Group of RadianceM")
				.version("1.0.0")
				.license(getLicense());
	}

	private ExternalDocumentation getExternalDocumentation() {
		return new ExternalDocumentation()
				.description("A project for Group of the RadianceM")
				.url("https://gitee.com/xiaoting1111111/pyroxene.git");
	}

}
